package com.company;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 循环List处理字段
 *
 * @date : 2024-06-20 上午11:33
 */

public class P070_ListLoopModify {

    public static void main(String[] args) {
        personListModify();
    }

    private static void personListModify() {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person(" 张三", 20));
        personList.add(new Person("李四 ", 21));
        personList.add(new Person(" 王五 ", 22));

        personList.forEach(person -> {
            person.setName(person.getName().trim());
            person.setAge(person.getAge() + 10);
        });
        System.out.println(personList);
    }

    @Data
    @AllArgsConstructor
    public static class Person {
        private String name;
        private int age;
    }

}
